package Servlet;

import Bean.LoginBean;
import Dao.Impl.StuDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/StuRegisterServlet")
public class StuRegisterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        LoginBean user=new LoginBean();
        user.setClss(req.getParameter("class"));
        user.setId(req.getParameter("id"));
        user.setName(req.getParameter("name"));
        user.setPassword(req.getParameter("password"));

        StuDaoImpl stu=new StuDaoImpl();

        stu.AddStu(user);

        req.getRequestDispatcher("login.jsp").forward(req,resp);
    }
}
